package com.ruoyi.scenery.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scenery.domain.SceneryReserve;
import com.ruoyi.scenery.service.ISceneryReserveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预订信息管理Controller
 * 
 * @author ruoyi
 * @date 2023-04-13
 */
@RestController
@RequestMapping("/scenery/reserve")
public class SceneryReserveController extends BaseController
{
    @Autowired
    private ISceneryReserveService sceneryReserveService;

    /**
     * 查询预订信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:reserve:list')")
    @GetMapping("/list")
    public TableDataInfo list(SceneryReserve sceneryReserve)
    {
        startPage();
        List<SceneryReserve> list = sceneryReserveService.selectSceneryReserveList(sceneryReserve);
        return getDataTable(list);
    }

    /**
     * 导出预订信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:reserve:export')")
    @Log(title = "预订信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SceneryReserve sceneryReserve)
    {
        List<SceneryReserve> list = sceneryReserveService.selectSceneryReserveList(sceneryReserve);
        ExcelUtil<SceneryReserve> util = new ExcelUtil<SceneryReserve>(SceneryReserve.class);
        util.exportExcel(response, list, "预订信息管理数据");
    }

    /**
     * 获取预订信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('scenery:reserve:query')")
    @GetMapping(value = "/{reserveId}")
    public AjaxResult getInfo(@PathVariable("reserveId") Long reserveId)
    {
        return success(sceneryReserveService.selectSceneryReserveByReserveId(reserveId));
    }

    /**
     * 新增预订信息管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:reserve:add')")
    @Log(title = "预订信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SceneryReserve sceneryReserve)
    {
        return toAjax(sceneryReserveService.insertSceneryReserve(sceneryReserve));
    }

    /**
     * 修改预订信息管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:reserve:edit')")
    @Log(title = "预订信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SceneryReserve sceneryReserve)
    {
        return toAjax(sceneryReserveService.updateSceneryReserve(sceneryReserve));
    }

    /**
     * 删除预订信息管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:reserve:remove')")
    @Log(title = "预订信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reserveIds}")
    public AjaxResult remove(@PathVariable Long[] reserveIds)
    {
        return toAjax(sceneryReserveService.deleteSceneryReserveByReserveIds(reserveIds));
    }
}
